$(function () {

    //初始化加载datagrid
    $('#dg1').datagrid({
        method: 'post',
        url: ROOT_PATH + '/workflow/flowManagement/findWorkItemList.shtml',
        queryParams: {
            sort: 'endTime',
            order: 'desc',
            queryState:7
         },
        //idField: 'id',
        fitColumns: true,
        pagination: true,
        rownumbers: true,
        sortOrder: true,
        striped: true,
        fit: true,
        columns: [[
            {field: 'id', width: 80, checkbox: true},
            {field: 'flowDisplayName', title: '业务流程', width: 80, sortable: true},
            {field: 'taskDisplayName', title: '流程环节', width: 80, sortable: true,
                formatter: function (value, row, index) {
                    var returnStr="<a onclick=\"flowMonitorByWorkItemId('"+row.id+"')\" style='color:blue;'>";
                    returnStr+=value;
                    returnStr+="</a>";
                    return returnStr;
                }},
            {field: 'businessContent', title: '业务描述', width: 80, sortable: true,
                formatter: function (value, row, index) {
                    var returnStr="<a onclick=\"openBusinessDetailPage('"+row.id+"')\" style='color:blue;'>";
                    returnStr+=value;
                    returnStr+="</a>";
                    return returnStr;
                }},
            {field: 'createdTime', title: '接收时间', width: 80, sortable: true},
            {field: 'endTime', title: '处理完成时间', width: 80, sortable: true},
            {field: 'state', title: '处理结果', width: 80, sortable: true,
                formatter: function (value, row, index) {
                    var returnStr=value==7?'<a>通过</a>':'<a style="color:red;">驳回</a>';
                    return returnStr;
                }}

        ]]
    });
    $('#btn_search').on("click", function () {
        var params=$('#tb1').find(':input').serializeJson();
        params.sort='endTime';
        params.order='desc';
        $('#dg1').datagrid('load',params);
    });

});
/***
 * 打开业务表单查看页面
 * @returns {boolean}
 */
function openBusinessDetailPage(workItemId){
    //打开业务表单
    WindowManager.openLayer({
        type: 2,
        title: '业务查看',
        area: ['1150px', '80%'],
        content: ROOT_PATH +"/workflow/flowManagement/toBusinessPage.shtml?workItemId="+workItemId+"&formType=0",
        end:function(){
            //$('#dg1').datagrid('reload');//刷新列表
        }
    });
}



